package com.example.withroadlogistics.MyTask;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.example.withroadlogistics.DemoInfo;
import com.example.withroadlogistics.R;
import com.example.withroadlogistics.until.DemoListAdapter;

public class WorkList extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menulist);//这个样式可以共用
        ListView demoList = (ListView) findViewById(R.id.mapList);
        // 添加ListItem，设置事件响应
        demoList.setAdapter(new DemoListAdapter(WorkList.this,DEMOS));//加载数组
        demoList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View v, int index, long arg3) {
                onListItemClick(index);
            }
        });
    }

    void onListItemClick(int index) { //监听列表菜单
        Intent intent;
        intent = new Intent(this, DEMOS[index].demoClass);
        this.startActivity(intent);
    }

    private static final DemoInfo[] DEMOS = {
            new DemoInfo(R.string.mytask_transport, R.string.mytask_desc_transport, Mytransport.class),//我的路线
            new DemoInfo(R.string.mytask_scheduling, R.string.mytask_desc_scheduling, Myscheduling.class),//我的排班
            new DemoInfo(R.string.mytask_history, R.string.mytask_desc_history, Historytransport.class),//我的历史
    };


}
